home *** CD-ROM | disk | FTP | other *** search
- #!/bin/tcsh
-
- #
- # MMinstall - install MMmalloc library
- # Gianni Mariani 9-Apr-1994
- #
- #
-
- echo "MMmalloc install proceedure"
-
- set MMLIBNAM = libmalloc.so
- set MMLIB = $MMLIBNAM
- set THELIB = /lib/libmalloc.so
- set ORIGLIB = /lib/libmalloc.so.orig
- set ARMFILE = /var/malloc/ArmMMmalloc
-
- if ( ! -w /lib ) then
- echo "You must be root to run $0"
- exit 1
- endif
-
- if ( ! -f $THELIB && ! -f $ORIGLIB ) then
- echo "Cannot find $THELIB : Aborting"
- exit 1
- endif
-
-
- # lets go and find the MMmalloc library
- if ( ! -f $MMLIB ) then
- set MMLIB = ${0:h}/$MMLIBNAM
- if ( ! -f $MMLIB ) then
- echo "Cannot find MMmalloc library"
- exit 1
- endif
- else
- # make sure we are damn sure that this is not being run
- # in /lib
- if ( $cwd == /lib ) then
- set MMLIB = ${0:h}/$MMLIBNAM
- if ( ! -f $MMLIB ) then
- echo "Cannot find MMmalloc library"
- exit 1
- endif
- endif
- endif
-
- # make sure that the original library is saved
- if ( ! -f $ORIGLIB ) then
- if ( -f $THELIB ) then
- ln $THELIB $ORIGLIB
- echo "== Linking the original malloc library for posterity"
- echo " $THELIB ----> $ORIGLIB"
- endif
- else
- echo "== Original malloc library exists and remains unscathed"
- echo " $ORIGLIB"
- endif
-
- echo "== To uninstall MMmalloc simply move"
- echo " $ORIGLIB ----> $THELIB"
- echo "== using the command below"
- echo ""
- echo " /bin/mv $ORIGLIB $THELIB"
- echo ""
-
-
- if ( ! -f $ARMFILE ) then
- if ( ! -d ${ARMFILE:h} ) then
- mkdir -p ${ARMFILE:h}
- chmod 755 ${ARMFILE:h}
- chown root.sys ${ARMFILE:h}
- touch $ARMFILE
- chmod 644 ${ARMFILE}
- chown root.sys ${ARMFILE}
- echo "== Recycle has been enabled by creating :"
- echo " ${ARMFILE}"
- echo "== Disable recycle by removing ${ARMFILE}"
- else
- echo "== Recycle is disabled with this file missing"
- echo " ${ARMFILE}"
- echo "== See MMmalloc README for more details"
- endif
- else
- echo "== Recycle is enabled - arm file exists"
- echo " ${ARMFILE}"
- endif
- echo ""
-
- # copy the MMmalloc library to /lib doing some fancy footwork
- # to make sure processes already using /lib/libmalloc.so don't
- # have their executable ripped out from underneath them.
-
- /bin/cp $MMLIB ${THELIB}.tmp
- chmod 444 ${THELIB}.tmp
- chown root.sys ${THELIB}.tmp
- /bin/mv ${THELIB}.tmp ${THELIB}
-
- echo "**** MMmalloc installed ****"
-
- exit 0
-
-